Skip to content

listener: allow TCP and UDP on the same port#17414

Merged
mattklein123 merged 3 commits intomainfrom
fix_tcp_udp_port_match
Jul 20, 2021
Merged

listener: allow TCP and UDP on the same port#17414
mattklein123 merged 3 commits intomainfrom
fix_tcp_udp_port_match

Conversation

@mattklein123
Copy link
Copy Markdown
Member

Fixes #15562

Risk Level: Low
Testing: Modified unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Fixes #15562

Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Copy Markdown
Member Author

cc @ggreenway @lambdai

Signed-off-by: Matt Klein <mklein@lyft.com>
@ggreenway
Copy link
Copy Markdown
Member

I think we may be better off adding ipproto (tcp or udp) to the address type, so that equality comparison works as expected. I think most people would intuitively expect that 1.1.1.1:80:TCP != 1.1.1.1:80:UDP. The OS considers them completely separate addresses, so probably our abstraction should also.

@mattklein123
Copy link
Copy Markdown
Member Author

I think we may be better off adding ipproto (tcp or udp) to the address type, so that equality comparison works as expected. I think most people would intuitively expect that 1.1.1.1:80:TCP != 1.1.1.1:80:UDP. The OS considers them completely separate addresses, so probably our abstraction should also.

OK, I can take a look at this. It will likely be a much larger change.

@ggreenway
Copy link
Copy Markdown
Member

OK, I can take a look at this. It will likely be a much larger change.

Yes, but I think it's the right way to do it. Probably can default to TCP to have a much smaller change. UDP is used far less at this point. Could later make a mechanical change to remove the default and specify TCP in all the places it is needed, if we want that for clarity.

@mattklein123
Copy link
Copy Markdown
Member Author

@ggreenway I looked at this briefly and I'm not sure that I agree that making the Address interface include TCP/UDP is the right thing to do. It's used in various places that don't care about that at all (DNS, IP tagging, etc.) and I think it's not a great abstraction.

How about this: a wrapper AddressAndProto which contains both the underlying address and the proto, and then define equality on that correctly. Then, we can use that inside the listener manager code and fix effected call sites. I think this will be more targeted and clear. WDYT?

@ggreenway
Copy link
Copy Markdown
Member

@ggreenway I looked at this briefly and I'm not sure that I agree that making the Address interface include TCP/UDP is the right thing to do. It's used in various places that don't care about that at all (DNS, IP tagging, etc.) and I think it's not a great abstraction.

How about this: a wrapper AddressAndProto which contains both the underlying address and the proto, and then define equality on that correctly. Then, we can use that inside the listener manager code and fix effected call sites. I think this will be more targeted and clear. WDYT?

I think we currently use it for two use cases: IP address, or IP:port. Maybe those two should be separate, and TCP/UDP should only be in the IP:port version. But that may turn into an enormous change. Or maybe leave the interfaces as they are, but replace all uses of port with a tuple of port:ipproto, but keep it optional (and defaulting to TCP for now). But i feel like anytime we have a port number, we need to know whether it is tcp or udp; it's not meaningful generically.

@mattklein123
Copy link
Copy Markdown
Member Author

Or maybe leave the interfaces as they are, but replace all uses of port with a tuple of port:ipproto, but keep it optional (and defaulting to TCP for now). But i feel like anytime we have a port number, we need to know whether it is tcp or udp; it's not meaningful generically.

I still think this is going to be incredibly invasive as there are string versions of address that would need to take into account proto, etc. I agree it's doable but I'm just not sure it's worth the churn. I will keep this going as a side project but given the scope of this change I will put it on hold for now as I don't have the near term time.

/wait

@mattklein123 mattklein123 added the no stalebot Disables stalebot from closing an issue label Jul 20, 2021
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it may not be worth the churn. I think this change looks good to solve the immediate problem. We can decide in the future if we need a wholistic solution or not.

@mattklein123
Copy link
Copy Markdown
Member Author

OK, let me open a tracking issue for a better fix.

@mattklein123
Copy link
Copy Markdown
Member Author

Cross linking #17429 for posterity on a better long term fix.

@mattklein123 mattklein123 merged commit d483098 into main Jul 20, 2021
@mattklein123 mattklein123 deleted the fix_tcp_udp_port_match branch July 20, 2021 23:04
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no stalebot Disables stalebot from closing an issue waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

listener: replacing a listener with same port but TCP -> UDP crashes

3 participants